package cn.exrick.xboot.banner.service.serviceimpl;

import cn.exrick.xboot.banner.entity.Banner;
import cn.exrick.xboot.banner.mapper.BannerMapper;
import cn.exrick.xboot.banner.service.IBannerService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import java.util.List;
/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author yck
 * @since 2022-11-24
 */
@Service
@Transactional
public class BannerServiceImpl extends ServiceImpl<BannerMapper, Banner> implements IBannerService {


@Autowired
private BannerMapper bannerMapper;

@Override
public IPage<Banner> selectPage(Page<Banner> page, Banner banner){
        QueryWrapper<Banner> query = Wrappers.query();
        QueryWrapper<Banner> entityWrapper = getEntityWrapper(query, banner);
        entityWrapper.lambda().eq(Banner::getDel,0);
        entityWrapper.lambda().orderByDesc(Banner::getCreateTime);
        return bannerMapper.selectPage(page, entityWrapper);
        }




@Override
public List<Banner> selectList(Banner banner){
        QueryWrapper<Banner> query = Wrappers.query();
        QueryWrapper<Banner> entityWrapper = getEntityWrapper(query, banner);
        return bannerMapper.selectList(entityWrapper);
        }

/**
 *  公共查询条件
 * @param entityWrapper
 * @return
 */
public QueryWrapper<Banner> getEntityWrapper(QueryWrapper<Banner> entityWrapper,Banner banner){
        //条件拼接



        return entityWrapper;
        }
        }
